<?php if(!defined('SIDELOADED')) { echo 'Direct access is not allowed.'; }
/**
 * @author Tyil <info@tyil.nl>
 * @version 1.0 beta [30-03-2012]
 */

if(Session::Get('user') > 0) {
  
  $db = new Database();
  $db->Run('SELECT `id` FROM `users` ORDER BY `regdate` DESC LIMIT 0, 1;');
  $newUserId = $db->Result()->id;
  
  $db->Run('SELECT `creator` FROM `users_regkeys` WHERE `used`=' . $newUserId . ';');
  $recruiter = $db->Result()->creator;
  
  Website::View('page', array(
    'title' => 'Home',
    'content' => Website::View('home/welcome', array(
      
    )) . Website::View('home/newmember', array(
      'rookie' => new User($newUserId),
      'recruiter' => new User($recruiter)
    ))
  ), true);
  
} else {
  // User is not logged in
    
  Website::View('page', array(
    'title' => 'Login',
    'preTitle' => Website::View('login/css'),
    'postTitle' => Website::View('login/js'),
    'content' => Website::View('login/form') . Website::View('home/googleplus')
  ), true);
  
}
